function e(e) {
    return (e = e.toString())[1] ? e : "0" + e;
}

var t = function(e, t) {
    var n = e;
    n = n.replace(/spliter/g, "/");
    var a = new Date(n);
    return a.setDate(a.getDate()), a.getTime() - 288e5;
};

function n(e) {
    return (e = e.toString()).length >= 2 && "0" == e[0] ? e.substr(1) : e;
}

module.exports = {
    formatTime: function(t, n) {
        var a = [ "Y", "M", "D", "h", "m", "s" ], r = [], g = new Date(1e3 * t);
        for (var u in r.push(g.getFullYear()), r.push(e(g.getMonth() + 1)), r.push(e(g.getDate())), 
        r.push(e(g.getHours())), r.push(e(g.getMinutes())), r.push(e(g.getSeconds())), r) n = n.replace(a[u], r[u]);
        return n;
    },
    formatLongTime: function(t, n) {
        var a = [ "Y", "M", "D", "h", "m", "s" ], r = [], g = new Date();
        for (var u in g.setTime(t), r.push(g.getFullYear()), r.push(e(g.getMonth() + 1)), 
        r.push(e(g.getDate())), r.push(e(g.getHours())), r.push(e(g.getMinutes())), r.push(e(g.getSeconds())), 
        r) n = n.replace(a[u], r[u]);
        return n;
    },
    getTimeStamp: function() {
        return new Date().getTime();
    },
    formatYearMonthDay: function(t, n) {
        var a = new Date();
        a.setTime(t);
        var r = a.getFullYear(), g = a.getMonth() + 1, u = a.getDate();
        a.getHours(), a.getMinutes(), a.getSeconds();
        return [ r, g, u ].map(e).join(n);
    },
    formatHourMinite: function(t, n) {
        var a = new Date();
        a.setTime(t);
        var r = a.getHours(), g = a.getMinutes();
        a.getSeconds();
        return [ r, g ].map(e).join(n);
    },
    getTimeStampFromYearMonthDay: t,
    getWeekStartDate: function() {
        var e = new Date().getFullYear(), t = new Date().getMonth(), n = new Date().getDate(), a = new Date().getDay(), r = new Date(e, t, n - a + 1);
        return Date.parse(r);
    },
    formatDate: function(t) {
        return [ t.getFullYear(), t.getMonth() + 1, t.getDate() ].map(e).join("-");
    },
    getWeekEndDate: function() {
        var e = new Date().getFullYear(), t = new Date().getMonth(), n = new Date().getDate(), a = new Date().getDay(), r = new Date(e, t, n + (8 - a));
        return Date.parse(r);
    },
    getLongTimeWithDateAndTime: function(e, a, r, g) {
        var u = 0;
        if (u = t(e), r) {
            var o = r.split(g);
            if (2 == o.length) u += 60 * n(o[0]) * 60 * 1e3, u += 60 * n(o[1]) * 1e3;
        }
        return u;
    },
    getYear: function(e) {
        var t = new Date();
        return t.setTime(e), t.getFullYear();
    },
    getMonth: function(e) {
        var t = new Date();
        return t.setTime(e), t.getMonth() + 1;
    },
    getDay: function(e) {
        var t = new Date();
        return t.setTime(e), t.getDate();
    },
    getHour: function(e) {
        var t = new Date();
        return t.setTime(e), t.getHours();
    },
    getMinute: function(e) {
        var t = new Date();
        return t.setTime(e), t.getMinutes();
    },
    getSecond: function(e) {
        var t = new Date();
        return t.setTime(e), t.getSeconds();
    },
    dateLater: function(e, t) {
        var n = {}, a = new Array("周日", "周一", "周二", "周三", "周四", "周五", "周六"), r = new Date(e);
        r.setDate(r.getDate() + t);
        var g = r.getDay();
        return n.year = r.getFullYear(), n.month = r.getMonth() + 1 < 10 ? "0" + (r.getMonth() + 1) : r.getMonth() + 1, 
        n.day = r.getDate() < 10 ? "0" + r.getDate() : r.getDate(), n.week = a[g], n;
    },
    getWeekStartDateByLongDate: function(e) {
        var t = new Date();
        t.setTime(e);
        var n = t.getFullYear(), a = t.getMonth(), r = t.getDate(), g = t.getDay(), u = new Date(n, a, r - g + 1);
        return Date.parse(u);
    },
    getWeekEndDateByLongDatedate: function(e) {
        var t = new Date();
        t.setTime(e);
        var n = t.getFullYear(), a = t.getMonth(), r = t.getDate(), g = t.getDay(), u = new Date(n, a, r + (8 - g));
        return Date.parse(u);
    },
    getCurrentYearMonthDayTimeStamp: function() {
        var e = new Date(), t = "".concat(e.getFullYear(), "/").concat(e.getMonth() + 1, "/").concat(e.getDate()), n = new Date(t);
        return n.setDate(n.getDate()), n.getTime() - 288e5;
    },
    getDaysOfMonthInYear: function(e, t) {
        var n = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
        return e % 4 != 0 || e % 100 == 0 && e % 400 != 0 || (n[1] = 29), n[t - 1];
    },
    getDaysOfMonth: function(e, t) {
        return new Date(e, t, 0).getDate();
    }
};